@extends('layout.index', ['layout_title'=>'公众号配置'])
@section('layout_style')

@endsection
@section('layout_body')
    <!--  PAPER WRAP -->
    <table id="table" lay-filter="table"></table>
@endsection
@section('layout_script')
    <script>
        layui.use(['element','jquery','table'], function () {
            var $ = layui.jquery,
                table = layui.table;

            var tableMain = table.render(init_table_config({
                elem:'#table',
                url:'{{url("/chat/config")}}',
                cols:[[
                    {field: 'title', title: '配置名称', width:120, sort: false},
                    {field: 'value', title: '值', edit:'text'},
                    {field: 'updated_at', title: '配置时间', fixed:'right',width:200}
                ]]
            }, true));
            table.on('edit(table)', function (obj) {
                layer.confirm('确认修改?', {title: '提示'}, function (index) {
                    AjaxPost({
                        url:'{{url("chat/config")}}',
                        data:{key:obj.data.key,value:obj.value},
                        success:function (data) {
                            layer.close(index)
                            tableMain.reload()
                        }
                    })
                })
            })
        })
    </script>
@endsection